package com.example.mobile2021606163crw0507;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class ShowDataActivity extends AppCompatActivity {

    private TextView tvShowTitle;
    private TextView tvShowName;
    private TextView tvShowPassword;
    private TextView tvShowDataSupplier;
    private Button tvShowDataSelect;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_data);
        initView();
        Intent intent = getIntent();
        String person = intent.getStringExtra("person");
        tvShowName.setText(person);

        Bundle bundle = intent.getExtras();
        String password = bundle.getString("password");
        tvShowPassword.setText(password);
        tvShowDataSelect.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent1 = new Intent(ShowDataActivity.this,SupplierActivity.class);
                startActivityForResult(intent1,1);
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 1 && resultCode == RESULT_OK){
            String supplierName = data.getStringExtra("supplier");
            tvShowDataSupplier.setText(supplierName);
        }
    }

    private void initView() {
        tvShowTitle = (TextView) findViewById(R.id.tvShowTitle);
        tvShowName = (TextView) findViewById(R.id.tvShowName);
        tvShowPassword = (TextView) findViewById(R.id.tvShowPassword);
        tvShowDataSupplier = (TextView) findViewById(R.id.tvShowDataSupplier);
        tvShowDataSelect = (Button) findViewById(R.id.tvShowDataSelect);
    }
}